package com.dddframework.data.typehandlers;

import com.dddframework.core.utils.JsonKit;
import com.dddframework.data.typehandlers.type.LongList;
import lombok.extern.slf4j.Slf4j;

/**
 * 类型转换：Varchar <-> LongList，使用JsonArray存储
 *
 * @author Jensen
 * @公众号 架构师修行录
 * @date 2021/9/12 14:52
 * @since jdk1.8
 */
@Slf4j(topic = "### BASE-DATA : TypeHandlers ###")
public class LongListTypeHandler extends BaseStringTypeHandler<LongList> {
    public LongListTypeHandler() {
        log.debug("Loading LongListTypeHandler, type: LongList");
    }

    @Override
    protected String convert(LongList obj) {
        return JsonKit.toJson(obj);
    }

    @Override
    protected LongList parse(String result) {
        return LongList.convert(JsonKit.toList(result, Long.class));
    }
}
